package com.hs.learn.changestream;

import lombok.extern.slf4j.Slf4j;
import org.springframework.data.mongodb.core.messaging.Message;
import org.springframework.data.mongodb.core.messaging.MessageListener;
import org.springframework.stereotype.Component;

/**
 * @Description: change stream 监听器
 * @Author 胡尚
 * @Date: 2024/8/1 14:34
 */
@Component
@Slf4j
public class DocumentMessageListener<S,T> implements MessageListener<S, T> {

    @Override
    public void onMessage(Message<S, T> message) {

        // TODO 在监听器方法中完成自己的定制化需求

        log.info("Received Message in collection: {}", message.getProperties().getCollectionName());
        log.info("trawsource: {}", message.getRaw());
        log.info("tconverted: {}", message.getBody());
    }
}
